/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package supportlearning.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Huy
 */
@Entity
@Table(name = "Semester", catalog = "SupportLearningDB", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "Semester.findAll", query = "SELECT s FROM Semester s"),
    @NamedQuery(name = "Semester.findBySemesterId", query = "SELECT s FROM Semester s WHERE s.semesterId = :semesterId"),
    @NamedQuery(name = "Semester.findBySemesterName", query = "SELECT s FROM Semester s WHERE s.semesterName = :semesterName"),
    @NamedQuery(name = "Semester.findByDescription", query = "SELECT s FROM Semester s WHERE s.description = :description")})
public class Semester implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "SemesterId", nullable = false)
    private Integer semesterId;
    @Basic(optional = false)
    @Column(name = "SemesterName", nullable = false, length = 50)
    private String semesterName;
    @Column(name = "Description", length = 100)
    private String description;
    @JoinColumn(name = "CourceId", referencedColumnName = "CourseId", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Course course;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "semester", fetch = FetchType.EAGER)
    private List<Subject> subjectList;

    public Semester() {
    }

    public Semester(Integer semesterId) {
        this.semesterId = semesterId;
    }

    public Semester(Integer semesterId, String semesterName) {
        this.semesterId = semesterId;
        this.semesterName = semesterName;
    }

    public Integer getSemesterId() {
        return semesterId;
    }

    public void setSemesterId(Integer semesterId) {
        this.semesterId = semesterId;
    }

    public String getSemesterName() {
        return semesterName;
    }

    public void setSemesterName(String semesterName) {
        this.semesterName = semesterName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Course getCourse() {
        return course;
    }

    public void setCourse(Course course) {
        this.course = course;
    }

    public List<Subject> getSubjectList() {
        return subjectList;
    }

    public void setSubjectList(List<Subject> subjectList) {
        this.subjectList = subjectList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (semesterId != null ? semesterId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Semester)) {
            return false;
        }
        Semester other = (Semester) object;
        if ((this.semesterId == null && other.semesterId != null) || (this.semesterId != null && !this.semesterId.equals(other.semesterId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "supportlearning.entity.Semester[semesterId=" + semesterId + "]";
    }

}
